package com.shopcz.mx.shopcar.manager;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.shopcz.dao.GoodsCommentDao;
import com.shopcz.lsy.page.Page;
import com.shopcz.lsy.page.commentpage;
import com.shopcz.view.GoodscommentViewForDetail;

public class SearchComment extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf-8");
		String strcurrentPage=req.getParameter("currentPage");
		int currentPage=1;
		try{
			currentPage=Integer.parseInt(strcurrentPage);
		}catch(Exception e){
			currentPage=1;
		}
		String strid=req.getParameter("id");
		int goodsid=Integer.parseInt(strid);
		commentpage page=new commentpage();
		page.setCurrentPage(currentPage);
		GoodsCommentDao gsDao=new GoodsCommentDao();
		page=gsDao.queryCommentById(goodsid,currentPage);
		
		req.getSession().setAttribute("pagedata", page);
		req.getRequestDispatcher("/homepageAndDetail/commentpage.jsp").forward(req, resp);
		
	}
	
}
